<?php
namespace app\common\model;
use x\Xbase;
class Goods extends Xbase
{
    /**
     * 获取商品详情
     * @param type $id
     */
    public function detail($id)
    {
        $field = [
            'b.id',
            'b.title',
            'b.price',
            'b.description',
            'b.market_price',
            'b.spec',
            'b.content',
            'b.pics',
            'b.pic',
            'b.sales_volume',
            'b.point',
            'a.title as p_title',
            'a.price as p_price',
            'a.views as p_views',
            'a.id as goods_price_id',
            'a.stock as p_stock'
        ];
        $field = implode(",", $field);
        $sql = "
        select
            {$field}
        from
            goods_price a
        left join
            goods b
        on
            a.goods_id = b.id
        left join
            shop c
        on
            a.shop_id=c.id
        where
            a.id=?
            and b.status=0
        ";
        $rs = $this->db->query($sql,[$id],1);
        return $rs;
    }
}
